package com.qsign.sfrz_android.net;

import android.os.Handler;
import android.text.TextUtils;

import com.qsign.sfrz_android.activity.home.Model.FuheModel;
import com.qsign.sfrz_android.activity.home.ViewController.LoginActivity;
import com.qsign.sfrz_android.activity.login.Model.MyUserData;
import com.qsign.sfrz_android.base.MyApplication;
import com.qsign.sfrz_android.base.YcspUserDataShared;

import org.json.JSONObject;

public class RequestServiceImpl {

    /**
     *坯布 登陆接口
     *
     * @param handler
     * @param requestType
     */
    public static void bang_login(Handler handler, int requestType, String YHBH,String password) {

        JSONObject inputInfo = new JSONObject();

        try {
//"JY142"
            inputInfo.put("YHM", YHBH);
            inputInfo.put("YHKL", password);

        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "login";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }


    /**
     * 页面初始化统计当日匹数与重量
     * @param handler
     * @param requestType
     */
    public static void getInitInfo(Handler handler,int requestType, String userBean) {

        JSONObject inputInfo = new JSONObject();

        try {
            JSONObject jsonObject=new JSONObject(userBean);
            inputInfo.put("userBean", jsonObject);


        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName="TickettoinitApp" ;

        IServiceImpl.callWebMethod(handler, requestType, inputInfo , methodName);
    }



    /**
     * 根据三联单号带出数据
     * @param handler
     * @param requestType
     * @param clothTktNo
     */
    public static void getProductInfo(Handler handler,int requestType, String clothTktNo) {


        JSONObject inputInfo = new JSONObject();

        try {

            inputInfo.put("CLOTHTKTNO", clothTktNo);


        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName="TicketfetchDataApp" ;

        IServiceImpl.callWebMethod(handler, requestType, inputInfo , methodName);
    }






    /**
     * 判断胚布是否已经称重
     * @param handler
     * @param requestType
     * @param clothTktNo
     */
    public static void getIsStandard(Handler handler,int requestType, String clothTktNo) {


        JSONObject inputInfo = new JSONObject();

        try {

            inputInfo.put("CLOTHTKTNO", clothTktNo);


        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName="TicketisStandardApp" ;

        IServiceImpl.callWebMethod(handler, requestType, inputInfo , methodName);
    }






    /**
     * 判断三联单号是否已扫描
     * @param handler
     * @param requestType
     * @param clothTktNo
     */
//    public static void getIsExists(Handler handler,int requestType, String clothTktNo) {
//
//
//        JSONObject inputInfo = new JSONObject();
//
//        try {
//
//            inputInfo.put("CLOTHTKTNO", clothTktNo);
//
//
//        } catch (Exception e) {
//            // TODO: handle exception
//        }
//        String methodName="TicketisExistsApp" ;
//
//        IServiceImpl.callWebMethod(handler, requestType, inputInfo , methodName);
//    }



    /**
     * 页面初始化统计当日匹数与重量
     * @param handler
     * @param requestType
     */
    public static void getBanList(Handler handler,int requestType, String userBean) {

        JSONObject inputInfo = new JSONObject();

        try {
            JSONObject jsonObject=new JSONObject(userBean);
            inputInfo.put("userBean", jsonObject);


        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "TickettoListApp";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }

    /**
     * 获取系统时间
     *
     * @param handler
     * @param requestType
     */
    public static void jy_getsysdate(Handler handler, int requestType) {


        String methodName = "getSysdate";

        IServiceImpl.callWebMethod(handler, requestType, "", methodName);
    }

    public static void zz_getchejian(Handler handler, int requestType) {

        String methodName = "toQueryWorkShop";

        IServiceImpl.callWebMethod(handler, requestType, "", methodName);
    }

    /**
     * 检验 织造查询
     *
     * @param handler
     * @param requestType
     */
    public static void zz_query(Handler handler, int requestType, String WORKSHOP, String LISTDATE_FROM, String LISTDATE_TO, String CLOTHTKTNO, String MACHINENO_FROM, String MACHINENO_TO) {

        JSONObject inputInfo = new JSONObject();

        try {

            inputInfo.put("WORKSHOP", WORKSHOP);
            inputInfo.put("LISTDATE_FROM", LISTDATE_FROM);
            inputInfo.put("LISTDATE_TO", LISTDATE_TO);
            inputInfo.put("CLOTHTKTNO", CLOTHTKTNO);
            inputInfo.put("MACHINENO_FROM", MACHINENO_FROM);
            inputInfo.put("MACHINENO_TO", MACHINENO_TO);

        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "longFaultList";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }



    /**
     * 复核查询
     *
     * @param handler
     * @param requestType
     */
    public static void fh_query(Handler handler, int requestType, String CKDH) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("CKDH", CKDH);
            MyUserData userData=  YcspUserDataShared.getInstance(MyApplication.getInstance()).getUserdata();
            inputInfo.put("RYXXID", userData.getRYXXID());
            inputInfo.put("XM", userData.getXM());
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "whCottonStorbyCKDH";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }

    /**
     * 入库查询
     *
     * @param handler
     * @param requestType
     */
    public static void rk_query(Handler handler, int requestType, String TRAYCODE) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("TRAYCODE", TRAYCODE);
            MyUserData userData=  YcspUserDataShared.getInstance(MyApplication.getInstance()).getUserdata();
            inputInfo.put("RYXXID", userData.getRYXXID());
            inputInfo.put("XM", userData.getXM());
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "whCottonStorYLbyTrayNoRK";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }

    /**
     * 库位校验
     *
     * @param handler
     * @param requestType
     */
    public static void kw_valide(Handler handler, int requestType, String SPNUM) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("WHLOC", SPNUM);
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "whCottonStorCheckKW";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }

    /**
     * 入库
     *
     * @param handler
     * @param requestType
     */
    public static void ruku(Handler handler, int requestType, String LX,String SPNUM,String TRAYCODE) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("LX", LX);
            inputInfo.put("WHLOC", SPNUM);
            inputInfo.put("TRAYCODE", TRAYCODE);
            MyUserData userData=  YcspUserDataShared.getInstance(MyApplication.getInstance()).getUserdata();
            inputInfo.put("RYXXID", userData.getRYXXID());
            inputInfo.put("XM", userData.getXM());
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "whCottonStorStock";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }

    /**
     * 出库查询
     *
     * @param handler
     * @param requestType
     */
    public static void chuku_query(Handler handler, int requestType, String TRAYCODE,String LX,String bizno) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("TRAYCODE", TRAYCODE);
            inputInfo.put("LX", LX);

            if(LX.equals("PH")){
                inputInfo.put("BATCHNO", bizno);//批号
            }else if(LX.equals("SD")){
                inputInfo.put("TASKNO", bizno);//纱单
            }

        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "whCottonStorYLbyTrayNoCK";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }


    /**
     * 打印
     *
     * @param handler
     * @param requestType
     */
    public static void print(Handler handler, int requestType, String PKID,String TPZL) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("PKID", PKID);
            inputInfo.put("TPZL", TPZL);
            MyUserData userData=  YcspUserDataShared.getInstance(MyApplication.getInstance()).getUserdata();
            inputInfo.put("RYXXID", userData.getRYXXID());
            inputInfo.put("XM", userData.getXM());
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "whCottonStorTrayCode";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }
    public static void valide_shadan(Handler handler, int requestType, String TASKNO) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("TASKNO", TASKNO);
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName ="whCottonStorCheckTaskNo";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }
    //出库
    public static void chuku(Handler handler, int requestType, String zl, String tpbh, com.alibaba.fastjson.JSONObject jsonObject) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("TPZL", jsonObject.getString("TPZL"));
            inputInfo.put("CKZL", zl);
            inputInfo.put("TASKNO", jsonObject.getString("TASKNO"));
            inputInfo.put("SZNUMBER", jsonObject.getString("SZNUMBER"));
            inputInfo.put("SCHEDTLID", jsonObject.getString("SCHEDTLID"));
            inputInfo.put("WHLOC", jsonObject.getString("WHLOC"));
            inputInfo.put("TRAYCODE", tpbh);
            MyUserData userData=  YcspUserDataShared.getInstance(MyApplication.getInstance()).getUserdata();
            inputInfo.put("RYXXID", userData.getRYXXID());
            inputInfo.put("XM", userData.getXM());
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName ="whCottonStorDelivery";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }


    public static void ph_query(Handler handler, int requestType, String pihao) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("BATCHNO", pihao);
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "whCottonStorCheckKWbyPH";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }

    public static void sd_query(Handler handler, int requestType, String shadan) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("TASKNO", shadan);
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "whCottonStorCheckTaskNo";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }

    public static void update(Handler handler, int requestType){
        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("appname", "原料库存数字化app");
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "autoUpdate";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }


    /**
     * 批号复核查询
     *
     * @param handler
     * @param requestType
     */
    public static void pihao_query(Handler handler, int requestType, String CKDH) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("BATCHNO", CKDH);
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "whCottonStorYLbyBatchnoRK";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }

    /**
     * 批号复核列表
     *
     * @param handler
     * @param requestType
     */
    public static void pihao_itemlist(Handler handler, int requestType, FuheModel item) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("BATCHNO", item.getBATCHNO());
            inputInfo.put("YLID", item.getYLID());
            inputInfo.put("ORIPLACE", item.getORIPLACE());
            inputInfo.put("COLORNO", TextUtils.isEmpty(item.getCOLORNO())?"":item.getCOLORNO());
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "whCottonStorTPbyPHFH";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }

    /**
     * 批号打印
     *
     * @param handler
     * @param requestType
     */
    public static void pihaoprint(Handler handler, int requestType, FuheModel item,String TPZL) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("BATCHNO", item.getBATCHNO());
            inputInfo.put("YLID", item.getYLID());
            inputInfo.put("ORIPLACE", item.getORIPLACE());
            inputInfo.put("COLORNO", TextUtils.isEmpty(item.getCOLORNO())?"":item.getCOLORNO());
            inputInfo.put("TPZL", TPZL);
            MyUserData userData=  YcspUserDataShared.getInstance(MyApplication.getInstance()).getUserdata();
            inputInfo.put("RYXXID", userData.getRYXXID());
            inputInfo.put("XM", userData.getXM());
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "whCottonStorBatchnoByTrayCode";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }

    /**
     * 批号删除
     *
     * @param handler
     * @param requestType
     */
    public static void pihaodelete(Handler handler, int requestType,String PKID) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("PKID", PKID);
            MyUserData userData=  YcspUserDataShared.getInstance(MyApplication.getInstance()).getUserdata();
            inputInfo.put("RYXXID", userData.getRYXXID());
            inputInfo.put("XM", userData.getXM());
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "whCottonStorDelRKtp";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }

    /**
     * 复核查询
     *
     * @param handler
     * @param requestType
     */
    public static void fh_itemclick(Handler handler, int requestType, String PKID) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("PKID", PKID);
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "whCottonStorTPbyCKMX";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }

    /**
     * 登录
     *
     * @param handler
     * @param requestType
     */
    public static void login(Handler handler, int requestType, String name,String password) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("YHM", name);
            inputInfo.put("YHKL", password);
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "login";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }

    public static void printitem(Handler handler, int requestType, String TRAYCODE) {

        JSONObject inputInfo = new JSONObject();
        try {
            inputInfo.put("TRAYCODE", TRAYCODE);
        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "whCottonStorPrint";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }

}
